﻿using System.Web;

namespace BM.Tools.WebControls.MForm.Example.Core
{
    using System;
    using System.Web.UI.WebControls;

    public partial class Navigation : System.Web.UI.Page
    {
        /// <summary>
        /// Gets or sets a value indicating whether ToolBoxNavigationEnabled.
        /// </summary>
        public static bool ToolBoxNavigationEnabled
        {
            get
            {
                var toolBoxNavigation = HttpContext.Current.Session["ToolBoxNavigation"];
                return toolBoxNavigation != null && (bool)toolBoxNavigation;
            }
            set
            {
                HttpContext.Current.Session["ToolBoxNavigation"] = value;
            }
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            CheckBoxDiv.Style.Add("border", "1px solid " + CheckBoxDivColor);
            ToolboxNavigationCheckBox.Text = "Toolbox Navigation " + (ToolBoxNavigationEnabled ? "enabled" : "disabled");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
               
        }        

        protected void ToggleToolboxNavigation(object sender, EventArgs e)
        {
            ToolBoxNavigationEnabled = (sender as CheckBox).Checked;
        }

        private string CheckBoxDivColor
        {
            get
            {
                return (ToolBoxNavigationEnabled) ? "green" : "red";
            }
        }
    }
}
